#ifndef	__BFX_REFXMLENTITY_H__
#define	__BFX_REFXMLENTITY_H__

namespace BFX
{

//////////////////////////////////////////////////////////////////////////////

// Represents a parsed or unparsed entity in the XML document.
class REFXMLEntity : public REFXMLNode
{
	friend class REFXMLLoader;
public:
	REFXMLEntity(const UniString& strName, const UniString& strData, const UniString& strPublicId, const UniString& strSystemId,
		const UniString& strNotationName, REFXMLDocument* pDoc);
	virtual ~REFXMLEntity();

	// Gets the name of the node.
	virtual UniString GetName() const;
	// Gets the name of the node without the namespace prefix.
	virtual UniString GetLocalName() const;

	// Gets the concatenated values of the entity node and all its children.
    virtual UniString GetInnerText() const;
	// The property is read-only and when tried to be set, exception will be thrown.
	virtual void SetInnerText(const UniString& str);

	// Gets the type of the node.
	virtual XMLNodeType GetNodeType() const;

	virtual bool IsContainer() const;

	//Without override these two functions, we can't guarantee that WriteTo()/WriteContent() functions will never be called
	virtual UniString GetOuterXml() const;

	virtual UniString GetInnerXml() const;
	virtual void SetInnerXml(const UniString& str);

	// Saves the node to the specified XmlWriter.
	virtual void WriteTo(REFXMLWriter* w) const;
	// Saves all the children of the node to the specified XmlWriter.
	virtual void WriteContentTo(REFXMLWriter* w) const;

	virtual UniString GetBaseURI() const;

	// Gets the value of the public identifier on the entity declaration.
	UniString GetPublicId() const;
	// Gets the value of the system identifier on the entity declaration.
	UniString GetSystemId() const;

	// Gets the name of the optional NDATA attribute on the entity declaration.
	UniString GetNotationName() const;

protected:
	virtual REFXMLLinkedNode* GetFirstNode() const;
	virtual void SetFirstNode(REFXMLLinkedNode* pNode);

	virtual REFXMLLinkedNode* GetLastNode() const;
	virtual void SetLastNode(REFXMLLinkedNode* pNode);

	virtual bool IsValidChildType(XMLNodeType type) const;

	void SetBaseURI(const UniString& strBaseURI);

protected:
	UniString	m_strPublicId;
	UniString	m_strSystemId;
	UniString	m_strNotationName;
	UniString	m_strName;
	UniString	m_strUnparsedReplacementStr;
	UniString	m_strBaseURI;

	REF<REFXMLLinkedNode>	m_pFirstNode;
	REFXMLLinkedNode*	m_pLastNode;
	mutable bool		m_bChildrenFoliating;
};

}	//	namespace BFX

#endif	//	__BFX_REFXMLENTITY_H__
